<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Array
  
    &mdash; FSelector Documentation
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '';
  if (relpath != '') relpath += '/';
</script>

  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index (A)</a> &raquo; 
    
    
    <span class="title">Array</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a id="class_list_link" href="#">Class List</a>
  
    <a id="method_list_link" href="#">Method List</a>
  
    <a id="file_list_link" href="#">File List</a>
  
</div>
      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Array
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Array</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/fselector/util.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>add functions to Array class</p>


  </div>
</div>
<div class="tags">
  

</div>






  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#ave-instance_method" title="#ave (instance method)">- (Float) <strong>ave</strong> </a>
    

    
      (also: #mean)
    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>average (mean).</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#median-instance_method" title="#median (instance method)">- (Float) <strong>median</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>median.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#pearson_r-instance_method" title="#pearson_r (instance method)">- (Float) <strong>pearson_r</strong>(v) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Pearson&#39;s correlation coefficient, 
two vectors must be of the same length.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#sd-instance_method" title="#sd (instance method)">- (Float) <strong>sd</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>standard deviation.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#sum-instance_method" title="#sum (instance method)">- (Float) <strong>sum</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>summation.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_scale-instance_method" title="#to_scale (instance method)">- (Array&lt;Float&gt;) <strong>to_scale</strong>(min = 0.0, max = 1.0) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>scale to [min, max].</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_sym-instance_method" title="#to_sym (instance method)">- (Array&lt;Symbol&gt;) <strong>to_sym</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>convert to symbol.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_zscore-instance_method" title="#to_zscore (instance method)">- (Array&lt;Float&gt;) <strong>to_zscore</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>convert to z-score.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#var-instance_method" title="#var (instance method)">- (Float) <strong>var</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>variance.</p>
</div></span>
  
</li>

      
    </ul>
  



  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="ave-instance_method">
  
    - (<tt>Float</tt>) <strong>ave</strong> 
  

  
    <span class="aliases">Also known as:
    <span class="names"><span id='mean-instance_method'>mean</span></span>
    </span>
  
</p><div class="docstring">
  <div class="discussion">
    <p>average (mean)</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>average (mean)</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


14
15
16</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 14</span>

<span class='kw'>def</span> <span class='id identifier rubyid_ave'>ave</span>
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_sum'>sum</span> <span class='op'>/</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="median-instance_method">
  
    - (<tt>Float</tt>) <strong>median</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>median</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>median</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


22
23
24
25
26</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 22</span>

<span class='kw'>def</span> <span class='id identifier rubyid_median'>median</span>
  <span class='id identifier rubyid_len'>len</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
  <span class='id identifier rubyid_sorted'>sorted</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span>
  <span class='lparen'>(</span><span class='id identifier rubyid_len'>len</span> <span class='op'>%</span> <span class='int'>2</span> <span class='op'>==</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_sorted'>sorted</span><span class='lbracket'>[</span><span class='id identifier rubyid_len'>len</span><span class='op'>/</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='lparen'>(</span><span class='id identifier rubyid_sorted'>sorted</span><span class='lbracket'>[</span><span class='id identifier rubyid_len'>len</span><span class='op'>/</span><span class='int'>2</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span><span class='op'>+</span><span class='id identifier rubyid_sorted'>sorted</span><span class='lbracket'>[</span><span class='id identifier rubyid_len'>len</span><span class='op'>/</span><span class='int'>2</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span><span class='op'>/</span><span class='int'>2</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="pearson_r-instance_method">
  
    - (<tt>Float</tt>) <strong>pearson_r</strong>(v) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Pearson&#39;s correlation coefficient, 
two vectors must be of the same length</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>v</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Array (class)">Array</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>the second vector</p>
</div>
      
    </li>
  
</ul>

<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>Pearson&#39;s r</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 95</span>

<span class='kw'>def</span> <span class='id identifier rubyid_pearson_r'>pearson_r</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
        <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  two vectors must be of the same length!</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='op'>!=</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span>
  
  <span class='id identifier rubyid_sm'>sm</span><span class='comma'>,</span> <span class='id identifier rubyid_vm'>vm</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ave'>ave</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ave'>ave</span>
  <span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='comma'>,</span> <span class='id identifier rubyid_c'>c</span> <span class='op'>=</span> <span class='float'>0.0</span><span class='comma'>,</span> <span class='float'>0.0</span><span class='comma'>,</span> <span class='float'>0.0</span>
  
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>|</span>
    <span class='id identifier rubyid_a'>a</span> <span class='op'>+=</span> <span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='op'>-</span><span class='id identifier rubyid_sm'>sm</span><span class='rparen'>)</span><span class='op'>*</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='op'>-</span><span class='id identifier rubyid_vm'>vm</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_b'>b</span> <span class='op'>+=</span> <span class='lparen'>(</span><span class='id identifier rubyid_s'>s</span><span class='op'>-</span><span class='id identifier rubyid_sm'>sm</span><span class='rparen'>)</span><span class='op'>**</span><span class='int'>2</span>
    <span class='id identifier rubyid_c'>c</span> <span class='op'>+=</span> <span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='op'>-</span><span class='id identifier rubyid_vm'>vm</span><span class='rparen'>)</span><span class='op'>**</span><span class='int'>2</span>
  <span class='kw'>end</span>
  
  <span class='kw'>if</span> <span class='id identifier rubyid_b'>b</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</span> <span class='kw'>or</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</span>
    <span class='kw'>return</span> <span class='float'>0.0</span>
  <span class='kw'>else</span>
    <span class='kw'>return</span> <span class='id identifier rubyid_a'>a</span> <span class='op'>/</span> <span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_sqrt'>sqrt</span><span class='lparen'>(</span><span class='id identifier rubyid_b'>b</span><span class='rparen'>)</span> <span class='op'>/</span> <span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_sqrt'>sqrt</span><span class='lparen'>(</span><span class='id identifier rubyid_c'>c</span><span class='rparen'>)</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="sd-instance_method">
  
    - (<tt>Float</tt>) <strong>sd</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>standard deviation</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>standard deviation</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


41
42
43</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 41</span>

<span class='kw'>def</span> <span class='id identifier rubyid_sd'>sd</span>
  <span class='const'>Math</span><span class='period'>.</span><span class='id identifier rubyid_sqrt'>sqrt</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_var'>var</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="sum-instance_method">
  
    - (<tt>Float</tt>) <strong>sum</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>summation</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>sum, no need to use .to_f</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


7
8
9</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 7</span>

<span class='kw'>def</span> <span class='id identifier rubyid_sum'>sum</span>
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='float'>0.0</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_s'>s</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_s'>s</span><span class='op'>+</span><span class='id identifier rubyid_i'>i</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="to_scale-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Array (class)">Array</a></span>&lt;Float&gt;</tt>) <strong>to_scale</strong>(min = 0.0, max = 1.0) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>scale to [min, max]</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>min</span>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>0.0</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>lower bound</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>max</span>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>1.0</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>upper bound</p>
</div>
      
    </li>
  
</ul>

<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Array (class)">Array</a></span>&lt;Float&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>scaled numbers</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 51</span>

<span class='kw'>def</span> <span class='id identifier rubyid_to_scale'>to_scale</span><span class='lparen'>(</span><span class='id identifier rubyid_min'>min</span><span class='op'>=</span><span class='float'>0.0</span><span class='comma'>,</span> <span class='id identifier rubyid_max'>max</span><span class='op'>=</span><span class='float'>1.0</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_min'>min</span> <span class='op'>&gt;=</span> <span class='id identifier rubyid_max'>max</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_abort'>abort</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='kw'>__FILE__</span><span class='rbrace'>}</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='kw'>__LINE__</span><span class='rbrace'>}</span><span class='tstring_content'>]: \n</span><span class='tstring_end'>&quot;</span></span><span class='op'>+</span>
          <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>  min must be smaller than max!</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
  
  <span class='id identifier rubyid_old_min'>old_min</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_min'>min</span>
  <span class='id identifier rubyid_old_max'>old_max</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>

  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
    <span class='kw'>if</span> <span class='id identifier rubyid_old_min'>old_min</span> <span class='op'>==</span> <span class='id identifier rubyid_old_max'>old_max</span>
      <span class='id identifier rubyid_max'>max</span>
    <span class='kw'>else</span>
      <span class='id identifier rubyid_min'>min</span> <span class='op'>+</span> <span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='op'>-</span><span class='id identifier rubyid_old_min'>old_min</span><span class='rparen'>)</span><span class='op'>*</span><span class='lparen'>(</span><span class='id identifier rubyid_max'>max</span><span class='op'>-</span><span class='id identifier rubyid_min'>min</span><span class='rparen'>)</span><span class='op'>/</span><span class='lparen'>(</span><span class='id identifier rubyid_old_max'>old_max</span><span class='op'>-</span><span class='id identifier rubyid_old_min'>old_min</span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="to_sym-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>) <strong>to_sym</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>convert to symbol</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Array (class)">Array</a></span>&lt;Symbol&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>converted symbols</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


85
86
87</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 85</span>

<span class='kw'>def</span> <span class='id identifier rubyid_to_sym'>to_sym</span>
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='op'>|</span> <span class='id identifier rubyid_x'>x</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="to_zscore-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Array (class)">Array</a></span>&lt;Float&gt;</tt>) <strong>to_zscore</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>convert to z-score</p>

<p>ref: <a href="http://en.wikipedia.org/wiki/Standard_score">Wikipedia</a></p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="Array (class)">Array</a></span>&lt;Float&gt;</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>converted z-scores</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


75
76
77
78
79
80</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 75</span>

<span class='kw'>def</span> <span class='id identifier rubyid_to_zscore'>to_zscore</span>
  <span class='id identifier rubyid_ave'>ave</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ave'>ave</span>
  <span class='id identifier rubyid_sd'>sd</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_sd'>sd</span>

  <span class='kw'>return</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='op'>-</span><span class='id identifier rubyid_ave'>ave</span><span class='rparen'>)</span><span class='op'>/</span><span class='id identifier rubyid_sd'>sd</span> <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="var-instance_method">
  
    - (<tt>Float</tt>) <strong>var</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>variance</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Float</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>variance</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


31
32
33
34
35
36</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 31</span>

<span class='kw'>def</span> <span class='id identifier rubyid_var'>var</span>
  <span class='id identifier rubyid_u'>u</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ave'>ave</span>
  <span class='id identifier rubyid_v2'>v2</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='float'>0.0</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='comma'>,</span> <span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='op'>+</span><span class='lparen'>(</span><span class='id identifier rubyid_i'>i</span><span class='op'>-</span><span class='id identifier rubyid_u'>u</span><span class='rparen'>)</span><span class='op'>*</span><span class='lparen'>(</span><span class='id identifier rubyid_i'>i</span><span class='op'>-</span><span class='id identifier rubyid_u'>u</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
  
  <span class='id identifier rubyid_v2'>v2</span><span class='op'>/</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Mon Nov  5 11:19:44 2012 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.7.5 (ruby-1.9.3).
</div>

  </body>
</html>